package com.daiqee.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.daiqee.pojo.User;
import com.daiqee.dao.mapper.LoginMapper;
import com.daiqee.dao.mapper.UserMapper;

/**
 * 管理员账号登录
 * 
 * <br/>
 * @since JDK 1.8
 * @version  V2.1
 * @author RichardTang 
 * @date: 2018年5月8日 上午8:23:13
 * @package com.daiqee.service.impl
 * @copyright:Copyright (c) 2018, 1245811923@qq.com All Rights Reserved.
 */
@Service
public class LoginService{
	
	@Autowired
	private LoginMapper loginMapper;
	
	@Autowired
	private UserMapper userMapper;
	
	/**
	 * 根据User实体校验数据库中的账号和密码
	 * @Time 2018-1-20
	 * @author RichardTang
	 * @param user
	 * 				 	需要被查询的User实体
	 * @return 返回一个符合条件的实体,如果没有查询到着返回NULL
	 */
	public User loginUser(User user) {
		User tempUser = userMapper.selectOne(user);
		return tempUser;
	}

	/**
	 * 根据用户名查询用户
	 * @Time 2018-1-26
	 * @since 1.0
	 * @version 1.0
	 * @author RichardTang
	 * @param username
	 * 					需要查询的用户的用户名
	 * @return	返回查询到的用户
	 */
	public User queryByUsername(String username) {
		return loginMapper.findByUsername(username);
	}
}
